﻿<phone:PhoneApplicationPage x:Class="DeepmixRadioClient.MainPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                            xmlns:workflow="clr-namespace:DeepmixRadioClient.Workflow" xmlns:deepmixRadioClient="clr-namespace:DeepmixRadioClient"
                            xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Core"
                            xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
                            xmlns:deepMixWorkflow="clr-namespace:DeepMixWorkflow;assembly=DeepMixWorkflow"
                            mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
                            d:DataContext="{d:DesignInstance Type=workflow:Logic}"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait"
                            BackKeyPress="back_Pressed"
                            shell:SystemTray.IsVisible="False">
    <phone:PhoneApplicationPage.Resources>
        <Style TargetType="telerikPrimitives:RadBusyIndicator">
            <Setter Property="AnimationStyle" Value="AnimationStyle9" />
        </Style>
        <workflow:TimeSpaneConverter x:Key="TimeSpaneConverter" />
        <deepmixRadioClient:LocalizedStrings x:Key="LocalizedStrings" />
        <Style TargetType="controls:PanoramaItem">
            <Setter Property="CacheMode" Value="BitmapCache" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Stretch" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:PanoramaItem">
                        <Grid Background="{TemplateBinding Background}" Margin="0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <ContentControl x:Name="header" ContentTemplate="{TemplateBinding HeaderTemplate}"
                                            Content="{TemplateBinding Header}" FontSize="{StaticResource PhoneFontSizeExtraExtraLarge}"
                                            FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" Margin="12,-2,0,26"
                                            Foreground="White">
                                <ContentControl.RenderTransform>
                                    <TranslateTransform x:Name="headerTransform" />
                                </ContentControl.RenderTransform>
                            </ContentControl>
                            <ContentPresenter Content="{TemplateBinding Content}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="2" Grid.Row="1"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Margin" Value="0,-116,0,0" />
        </Style>
        <Storyboard x:Name="TimeLite">
            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                          Storyboard.TargetName="MoscowTimeTxt">
                <EasingColorKeyFrame KeyTime="0:0:0.1" Value="#FFF34040" />
                <EasingColorKeyFrame KeyTime="0:0:0.2" Value="#99FFFFFF" />
                <EasingColorKeyFrame KeyTime="0:0:0.3" Value="#FFEF3B3B" />
                <EasingColorKeyFrame KeyTime="0:0:0.4" Value="#99FFFFFF" />
            </ColorAnimationUsingKeyFrames>
        </Storyboard>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="1" Background="{StaticResource PhoneChromeBrush}">
            <TextBlock Grid.Row="0" x:Name="Txt" TextWrapping="Wrap"
                       Text="{Binding StatusText}"
                       Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Center" />
        </Grid>
        <!--Panorama control-->
        <controls:Panorama x:Name="Panorama" Foreground="White">
            <controls:Panorama.Title>
                <Grid>
                    <Image Source="logo.png" Width="500" Height="150" Margin="80,55,0,0" Stretch="Fill" Opacity="0.25" />
                    <Grid Margin="0,84,0,0">
                    </Grid>
                </Grid>
            </controls:Panorama.Title>
            <controls:Panorama.Background>
                <ImageBrush ImageSource="back.png" />
            </controls:Panorama.Background>
 
            <!--Panorama item one-->
            <controls:PanoramaItem
                Header="{Binding Path=Localizedresources.OnAir,Source={StaticResource LocalizedStrings}}" x:Name="OnAirPanorama"
                Foreground="White">
                <!--Double line list with text wrapping-->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <telerikPrimitives:RadDataBoundListBoxItem Grid.Row="0" Margin="0"
                                                               telerik:InteractionEffectManager.IsInteractionEnabled="True">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Tap">
                                <workflow:CallDataContextMethodAction MethodName="PlayRadio"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <StackPanel Orientation="Vertical" DataContext="{Binding CurrentOnAirTrack,UpdateSourceTrigger=Default}">
                            <TextBlock
                                Text="{Binding Path=Localizedresources.ArtistIs,Source={StaticResource LocalizedStrings}}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" Foreground="#99FFFFFF" />
                            <TextBlock Text="{Binding Artist}" Style="{StaticResource PhoneTextLargeStyle}"
                                       TextWrapping="Wrap" Margin="12,0,12,0" Foreground="White" />
                            <TextBlock
                                Text="{Binding Path=Localizedresources.TitleIs,Source={StaticResource LocalizedStrings}}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" Margin="12,6,12,0" Foreground="#99FFFFFF" />
                            <TextBlock Text="{Binding Title}" TextWrapping="Wrap"
                                       Style="{StaticResource PhoneTextLargeStyle}" Margin="12,0,12,0" Foreground="White" />
                        </StackPanel>
                    </telerikPrimitives:RadDataBoundListBoxItem>
                    <Rectangle Grid.Row="1" Height="2" Margin="20,30,164,30">
                        <Rectangle.Fill>
                            <LinearGradientBrush EndPoint="0.963,0.539" StartPoint="0.055,0.423">
                                <GradientStop Offset="0" Color="White" />
                                <GradientStop Color="Transparent" Offset="1" />
                                <GradientStop Color="White" Offset="0.482" />
                            </LinearGradientBrush>
                        </Rectangle.Fill>
                    </Rectangle>
                    <Rectangle Grid.Row="2" Margin="12,12,12,30" UseLayoutRounding="True" OpacityMask="White"
                               Name="PaparRect" >
                        <Rectangle.Fill>
                            <ImageBrush Stretch="UniformToFill" ImageSource="306825_10151350775686554_330695706_n.jpg"/> <!--todo:  перестали выкладывать картинку Binding Image}-->
                        </Rectangle.Fill>
                    </Rectangle>
                </Grid>

            </controls:PanoramaItem>
            <controls:PanoramaItem
                Header="{Binding Path=Localizedresources.Program,Source={StaticResource LocalizedStrings}}"
                d:DataContext="{d:DesignData /SampleData/DeepMixTrackContainerSampleData.xaml}" Foreground="White">
                <Grid>
                    <Grid Margin="0,0,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="auto" />
                            <RowDefinition />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
<!-- ReSharper disable Xaml.StaticResourceNotResolved -->
                        <TextBlock Name="MoscowTimeTxt" Style="{StaticResource PhoneTextSubtleStyle}" Grid.Row="3" Margin="12,7,12,8" FontWeight="Bold"
                                   HorizontalAlignment="Center">
<!-- ReSharper restore Xaml.StaticResourceNotResolved -->
                            <TextBlock.Text>
                                <Binding Path="MoscowTime">
                                    <Binding.Converter>
                                        <workflow:TimeToMoscowTimeTextConverter/>
                                    </Binding.Converter>
                                </Binding>
                            </TextBlock.Text>
                        </TextBlock>
                        <telerikPrimitives:RadDataBoundListBox Margin="0,12,12,0" Grid.Row="2" x:Name="ProgramLst"
                                                               ItemsSource="{Binding Program}"
                                                               EmptyContent="{Binding Path=Localizedresources.NoData,Source={StaticResource LocalizedStrings}}"
                                                               EmptyContentDisplayMode="DataSourceEmpty" telerik:InteractionEffectManager.IsInteractionEnabled="True">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="ItemTap">
                                    <workflow:CallDataContextMethodAction ArgumentsPathForParameter="Item.DataContext" MethodName="ProgramClicked" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                            <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Margin="12,0,12,17" Width="432" MinHeight="78" Tag="{Binding Link}"
                                                d:DataContext="{d:DesignInstance deepMixWorkflow:DeepMixTrack}">
                                        <TextBlock
                                            Text="{Binding StartTime, Converter={StaticResource TimeSpaneConverter}}" Style="{StaticResource PhoneTextLargeStyle}"
                                            Margin="0,0,0,-16" HorizontalAlignment="Center">
                                            <TextBlock.Foreground>
                                                <Binding Path="IsSelected" Mode="OneWay">
                                                    <Binding.Converter>
                                                        <workflow:BoolToBrushConverter />
                                                    </Binding.Converter>
                                                </Binding>
                                            </TextBlock.Foreground>
                                        </TextBlock>
                                        <TextBlock Text="{Binding Title}" TextWrapping="Wrap"
                                                   Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="0,0,0,0">
                                            <TextBlock.Foreground>
                                                <Binding Path="IsSelected" Mode="OneWay">
                                                    <Binding.Converter>
                                                        <workflow:BoolToBrushConverter />
                                                    </Binding.Converter>
                                                </Binding>
                                            </TextBlock.Foreground>
                                        </TextBlock>
<!-- ReSharper disable Xaml.StaticResourceNotResolved -->
                                        <TextBlock Text="{Binding Artist}" TextWrapping="Wrap" Margin="0,-6,0,0"
                                                   Style="{StaticResource PhoneTextSubtleStyle}" MaxWidth="432">
<!-- ReSharper restore Xaml.StaticResourceNotResolved -->
                                            <TextBlock.Foreground>
                                                <Binding Path="IsSelected" Mode="OneWay">
                                                    <Binding.Converter>
                                                        <workflow:BoolToBrushConverter />
                                                    </Binding.Converter>
                                                </Binding>
                                            </TextBlock.Foreground>
                                        </TextBlock>
                                    </StackPanel>
                                </DataTemplate>
                            </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                        </telerikPrimitives:RadDataBoundListBox>
                    </Grid>
                    <Border>
                        <Border.Visibility>
                            <Binding ElementName="ProgramLst" Path="ItemsSource">
                                <Binding.Converter>
                                    <workflow:NullOrZeroToVisibleConverter />
                                </Binding.Converter>
                            </Binding>
                        </Border.Visibility>
                        <telerikPrimitives:RadBusyIndicator
                            Content="{Binding Path=Localizedresources.Loading,Source={StaticResource LocalizedStrings}}">
                            <telerikPrimitives:RadBusyIndicator.IsRunning>
                                <Binding ElementName="ProgramLst" Path="ItemsSource">
                                    <Binding.Converter>
                                        <workflow:NullOrZeroToVisibleConverter ReturnBool="True" />
                                    </Binding.Converter>
                                </Binding>
                            </telerikPrimitives:RadBusyIndicator.IsRunning>
                        </telerikPrimitives:RadBusyIndicator>
                    </Border>
                </Grid>
            </controls:PanoramaItem>
            <!--Panorama item two-->
            <!--Use 'Orientation="Horizontal"' to enable a panel that lays out horizontally-->
            <controls:PanoramaItem
                Header="{Binding Path=Localizedresources.Selected,Source={StaticResource LocalizedStrings}}"
                d:DataContext="{d:DesignData /SampleData/DeepMixTrackContainerSampleData.xaml}" Foreground="White">
                <!--Double line list with image placeholder and text wrapping-->
                <Grid>
                    <telerikPrimitives:RadDataBoundListBox x:Name="SelLst" Margin="12,0,12,0"
                                                           ItemsSource="{Binding Selected}" telerik:InteractionEffectManager.IsInteractionEnabled="True"
                                                           EmptyContent="{Binding Path=Localizedresources.NoData,Source={StaticResource LocalizedStrings}}"
                                                           EmptyContentDisplayMode="DataSourceEmpty">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="ItemTap">
                                <workflow:CallDataContextMethodAction ArgumentsPathForParameter="Item.DataContext" MethodName="PlaySelectedTrack" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17" Width="432" MinHeight="78" Tag="{Binding Link}"
                                            d:DataContext="{d:DesignInstance deepMixWorkflow:DeepMixTrack}">
                                    <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Margin="0"
                                               Style="{StaticResource PhoneTextExtraLargeStyle}">
                                        <TextBlock.Foreground>
                                            <Binding Path="IsSelected" Mode="OneWay">
                                                <Binding.Converter>
                                                    <workflow:BoolToBrushConverter />
                                                </Binding.Converter>
                                            </Binding>
                                        </TextBlock.Foreground>
                                    </TextBlock>
<!-- ReSharper disable Xaml.StaticResourceNotResolved -->
                                    <TextBlock Text="{Binding Artist}" TextWrapping="Wrap" Margin="0,-6,0,0"
                                               Style="{StaticResource PhoneTextSubtleStyle}">
<!-- ReSharper restore Xaml.StaticResourceNotResolved -->
                                        <TextBlock.Foreground>
                                            <Binding Path="IsSelected" Mode="OneWay">
                                                <Binding.Converter>
                                                    <workflow:BoolToBrushConverter />
                                                </Binding.Converter>
                                            </Binding>
                                        </TextBlock.Foreground>
                                    </TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                    </telerikPrimitives:RadDataBoundListBox>
                    <Border>
                        <Border.Visibility>
                            <Binding ElementName="SelLst" Path="ItemsSource">
                                <Binding.Converter>
                                    <workflow:NullOrZeroToVisibleConverter />
                                </Binding.Converter>
                            </Binding>
                        </Border.Visibility>
                        <telerikPrimitives:RadBusyIndicator
                            Content="{Binding Path=Localizedresources.Loading,Source={StaticResource LocalizedStrings}}">
                            <telerikPrimitives:RadBusyIndicator.IsRunning>
                                <Binding ElementName="SelLst" Path="ItemsSource">
                                    <Binding.Converter>
                                        <workflow:NullOrZeroToVisibleConverter ReturnBool="True" />
                                    </Binding.Converter>
                                </Binding>
                            </telerikPrimitives:RadBusyIndicator.IsRunning>
                        </telerikPrimitives:RadBusyIndicator>
                    </Border>
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
        <!--<Border Background="{StaticResource LoadingBorderBrush}">
            <Border.Visibility>
                <Binding ElementName="onAirPanel" Path="DataContext">
                    <Binding.Converter>
                        <Workflow:NullOrZeroToVisibleConverter checkDeepMix="True" />
                    </Binding.Converter>
                </Binding>
            </Border.Visibility>
            <telerikPrimitives:RadBusyIndicator
                Content="{Binding Path=Localizedresources.Loading,Source={StaticResource LocalizedStrings}}">
                <telerikPrimitives:RadBusyIndicator.IsRunning>
                    <Binding ElementName="onAirPanel" Path="DataContext">
                        <Binding.Converter>
                            <Workflow:NullOrZeroToVisibleConverter checkDeepMix="True" ReturnBool="True" />
                        </Binding.Converter>
                    </Binding>
                </telerikPrimitives:RadBusyIndicator.IsRunning>
            </telerikPrimitives:RadBusyIndicator>
        </Border>-->
        <Border Height="200" Margin="50,0,50,0" Background="{StaticResource PhoneBackgroundBrush}" Opacity="0.9" CornerRadius="10">
            <Border.Visibility>
                <Binding Path="IsError" FallbackValue="Collapsed">
                    <Binding.Converter>
                        <telerik:BoolToVisibilityConverter/>
                        </Binding.Converter>
                </Binding>
            </Border.Visibility>
            <TextBlock
                Text="{Binding Path=Localizedresources.ConnectionError,Source={StaticResource LocalizedStrings}}"
                HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" Style="{StaticResource PhoneTextLargeStyle}" />
        </Border>
        <Border Name="AboutBorder" Tap="closeaboutBorder_Clicked" Background="{StaticResource PhoneBackgroundBrush}"
                Visibility="Collapsed">
            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Text="{Binding Path=Localizedresources.About,Source={StaticResource LocalizedStrings}}"
                               Grid.Row="0" HorizontalAlignment="Left" Style="{StaticResource PhoneTextTitle1Style}"
                               Foreground="{StaticResource PhoneForegroundBrush}" />
                    <TextBlock Name="AboutTxt" Grid.Row="1" Text="Loading" TextWrapping="Wrap"
                               HorizontalAlignment="Left" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,17,12,0"
                               Foreground="{StaticResource PhoneForegroundBrush}" />
                    <HyperlinkButton
                        Content="{Binding Path=Localizedresources.DeeMixSite,Source={StaticResource LocalizedStrings}}" Grid.Row="2"
                        HorizontalAlignment="Left" Click="goDeepMix_Clicked" Foreground="{StaticResource PhoneForegroundBrush}" />
                </Grid>
            </ScrollViewer>
        </Border>
        <Border Background="{StaticResource PhoneBackgroundBrush}" Name="WelcomeStreen" Tap="close_Welcome"
                Visibility="Collapsed">
            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <TextBlock
                        Text="{Binding Path=Localizedresources.WellcomeHeader,Source={StaticResource LocalizedStrings}}" Grid.Row="0"
                        HorizontalAlignment="Left" Style="{StaticResource PhoneTextTitle1Style}" Margin="12"
                        Foreground="{StaticResource PhoneForegroundBrush}" />
                    <TextBlock Name="WelcomeTxt" Grid.Row="1" Text="Loading" TextWrapping="Wrap"
                               HorizontalAlignment="Left" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,17,12,0"
                               Foreground="{StaticResource PhoneForegroundBrush}" />
                    <HyperlinkButton HorizontalAlignment="Left"
                                     Content="{Binding Path=Localizedresources.DeeMixSite,Source={StaticResource LocalizedStrings}}" Grid.Row="2"
                                     Click="goDeepMix_Clicked" Foreground="{StaticResource PhoneForegroundBrush}" />
                </Grid>
            </ScrollViewer>
        </Border>
    </Grid>
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Loading" Click="update_Clicked" />
                <shell:ApplicationBarMenuItem Text="Loading" Click="showSettings_Clicked" />
                <shell:ApplicationBarMenuItem Text="Loading" Click="showAbout_Clicked" />
            </shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.transport.rew.rest.png" Text="Loading"
                                            Click="goBack_Clicked" />
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.transport.pause.rest.png" Text="Loading"
                                            Click="play_Clicked" />
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.stop.rest.png" Text="Loading" Click="stop_Clicked" />
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.transport.ff.rest.png" Text="Loading"
                                            Click="goNext_Clicked" />

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>